package com.yulebaby.callsenter.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yulebaby.callsenter.R;
import com.yulebaby.callsenter.bean.PreTranRecordTodayBean;
import com.yulebaby.callsenter.global.Constant;
import com.yulebaby.callsenter.utils.DateUtil;

import java.util.List;

/**
 * Author: Zhangbo
 * Time: 2017/2/4
 */
public class ActualTranNotesTodayAdapter extends BaseQuickAdapter<PreTranRecordTodayBean, BaseViewHolder> {

    public ActualTranNotesTodayAdapter(List<PreTranRecordTodayBean> data) {
        super(R.layout.item_track_notes, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, PreTranRecordTodayBean bean) {
        TextView tv_trackNone = baseViewHolder.getView(R.id.tv_trackprogress_none);
        TextView tv_trackExist = baseViewHolder.getView(R.id.tv_trackprogress_exist);
        View rl_trackProgress = baseViewHolder.getView(R.id.rl_trackprogress);
        baseViewHolder.setText(R.id.tv_tracktime, DateUtil.formatDateTimeDetail(bean.getVisit_time()))
                .setText(R.id.tv_name, checkNull(bean.getCustomerName()))
                .setText(R.id.tv_location, checkNull(bean.getZone()))
                .setText(R.id.tv_trackbody, checkNull(bean.getRemarks()))
                .addOnClickListener(R.id.rl_trackprogress);

        if (bean.getTrack_pro() > 3) {
            tv_trackNone.setVisibility(View.GONE);
            tv_trackExist.setVisibility(View.VISIBLE);
            rl_trackProgress.setClickable(true);
        } else {
            tv_trackNone.setVisibility(View.VISIBLE);
            tv_trackExist.setVisibility(View.GONE);
            rl_trackProgress.setClickable(false);
        }
        switch (bean.getTrack_pro()) {
            case Constant.TrackProgress.STATE_NONE:
                tv_trackNone.setText("无");
                break;
            case Constant.TrackProgress.STATE_INTENTION:
                tv_trackNone.setText("确认客户意向");
                break;
            case Constant.TrackProgress.STATE_DEMANDS:
                tv_trackNone.setText("客户明确表述需求");
                break;
            case Constant.TrackProgress.STATE_VISITSTORE:
                tv_trackNone.setText("已阅览资料或参观店面");
                break;
            case Constant.TrackProgress.STATE_SUPERIORITY:
                tv_trackExist.setText("明确知晓项目优势");
                break;
            case Constant.TrackProgress.STATE_CUSTOMERVISIT:
                tv_trackExist.setText("客户到访");
                break;
            case Constant.TrackProgress.STATE_SIGN:
                tv_trackExist.setText("已签约商铺");
                break;
            case Constant.TrackProgress.STATE_PAYMONEY:
                tv_trackExist.setText("签合同并打款到账");
                break;
        }
    }

    /**
     * 判断是否为空
     *
     * @param string
     * @return
     */
    public String checkNull(String string) {
        if (TextUtils.isEmpty(string)) {
            return "";
        }
        return string;
    }
}
